<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全选全不选</title>
    <script>
        function fn(){
            let all = document.getElementById("all");
            let emps = document.getElementsByName("emp");
            for(let i = 0; i < emps.length; i++){
                emps[i].checked = all.checked;
            }
        }
    </script>
</head>
<body>
<table border="1">
    <tr>
        <th><input type="checkbox" id="all" onclick="fn()">全选</th>
        <th>编号</th>
        <th>姓名</th>
        <th>工资</th>
    </tr>
    <tr>
        <td><input name="emp" type="checkbox"></td>
        <td>1</td>
        <td>admin</td>
        <td>5000.0</td>
    </tr>
    <tr>
        <td><input name="emp" type="checkbox"></td>
        <td>2</td>
        <td>alice</td>
        <td>5000.0</td>
    </tr>
    <tr>
        <td><input name="emp" type="checkbox"></td>
        <td>3</td>
        <td>tom</td>
        <td>5000.0</td>
    </tr>
    <tr>
        <td><input name="emp" type="checkbox"></td>
        <td>4</td>
        <td>jack</td>
        <td>5000.0</td>
    </tr>
</table>
</body>
</html>